home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_11 / pjp / ostream < prev    next >
Encoding:
Text File  |  1994-10-02  |  2.3 KB  |  74 lines

  1. ------------- Listing 1: The file ostream ------------------
  2.  
  3. // ostream standard header
  4. #ifndef _OSTREAM_
  5. #define _OSTREAM_
  6. #include <streambuf>
  7.         // class ostream
  8. class ostream : virtual public ios {
  9. public:
  10.     ostream(streambuf *_S)
  11.         : ios(_S) {}
  12.     ostream(_Uninitialized)
  13.         : ios(_Noinit) {}
  14.     virtual ~ostream();
  15.     _Bool opfx();
  16.     void osfx();
  17.     ostream& operator<<(ostream& (*_F)(ostream&))
  18.         {return ((*_F)(*this)); } 
  19.     ostream& operator<<(ios& (*_F)(ios&))
  20.         {(*_F)(*(ios *)this); return (*this); }
  21.     ostream& operator<<(const char *);
  22.     ostream& operator<<(char _C)
  23.         {put(_C); return (*this); }
  24.     ostream& operator<<(unsigned char _C)
  25.         {return (*this << (char)_C); }
  26.     ostream& operator<<(short _X)
  27.         {return (_Print(&"B hoB hxB hd"[_If()], _X)); }
  28.     ostream& operator<<(unsigned short _X)
  29.         {return (_Print(&"B hoB hxB hu"[_If()], _X)); }
  30.     ostream& operator<<(int _X)
  31.         {return (_Print(&"B  oB  xB  d"[_If()], _X)); }
  32.     ostream& operator<<(unsigned int _X)
  33.         {return (_Print(&"B  oB  xB  u"[_If()], _X)); }
  34.     ostream& operator<<(long _X)
  35.         {return (_Print(&"B loB lxB ld"[_If()], _X)); }
  36.     ostream& operator<<(unsigned long _X)
  37.         {return (_Print(&"B loB lxB lu"[_If()], _X)); }
  38.     ostream& operator<<(float _X)
  39.         {return (_Print(&"P. eP. fP. g"[_Ff()], _Pr(), _X)); }
  40.     ostream& operator<<(double _X)
  41.         {return (_Print(&"P.leP.lfP.lg"[_Ff()], _Pr(), _X)); }
  42.     ostream& operator<<(long double _X)
  43.         {return (_Print(&"P.LeP.LfP.Lg"[_Ff()], _Pr(), _X)); }
  44.     ostream& operator<<(void *);
  45.     ostream& operator<<(streambuf&);
  46.     ostream& put(char);
  47.     ostream& write(const char *, int);
  48.     ostream& write(const unsigned char *_S, int _N)
  49.         {return (write((const char *)_S, _N)); }
  50.     ostream& flush();
  51. #if _HAS_SIGNED_CHAR
  52.     ostream& operator<<(signed char _C)
  53.         {return (*this << (char)_C); }
  54.     ostream& write(const signed char *_S, int _N)
  55.         {return (write((const char *)_S, _N)); }
  56. #endif /* _HAS_SIGNED_CHAR */
  57. protected:
  58.     int _Ff()
  59.         {return ((flags() & floatfield) == scientific ? 0
  60.             : (flags() & floatfield) == fixed ? 4 : 8); }
  61.     int _If()
  62.         {return ((flags() & basefield) == oct ? 0
  63.             : (flags() & basefield) == hex ? 4 : 8); }
  64.     void _Pad(const char *, char *, int);
  65.     int _Pr();
  66.     ostream& _Print(const char *, ...);
  67.     };
  68.         // manipulators
  69. ostream& endl(ostream&);
  70. ostream& ends(ostream&);
  71. ostream& flush(ostream&);
  72. #endif
  73.  
  74.